package com.gz.steak.modules.system.controller;

import com.gz.steak.common.aspect.anotation.Auth;
import com.gz.steak.common.web.base.BaseController;
import com.gz.steak.common.consts.Role;
import com.gz.steak.common.web.result.Result;
import com.gz.steak.modules.system.pojo.model.SysRoleModel;
import com.gz.steak.modules.system.pojo.vo.SysRoleVo;
import com.gz.steak.modules.system.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author 刘牌
 * @Date 2020/3/20 0020 21:56
 * @Version 1.0
 */
@RestController
@RequestMapping("/role")
public class SysRoleController extends BaseController {

    @Autowired
    private SysRoleService sysRoleService;

    /**
     * 角色列表
     * @return
     */
    @GetMapping("/get")
    public Result get(){
        List<SysRoleVo> list = sysRoleService.get();
        return Result.success(list);
    }

    @PostMapping("/save")
    @Auth(Role.EDITOR)
    public Result save(@RequestBody SysRoleModel sysRoleModel , HttpServletRequest request){
        sysRoleService.save(sysRoleModel,request);
        return Result.success("success");
    }
}
